import 'package:nyh_motorcade_app/entity/cash_flow_entity.dart';

cashFlowEntityFromJson(CashFlowEntity data, Map<String, dynamic> json) {
	if (json['page'] != null) {
		data.page = json['page'] is String
				? int.tryParse(json['page'])
				: json['page'].toInt();
	}
	if (json['pageSize'] != null) {
		data.pageSize = json['pageSize'] is String
				? int.tryParse(json['pageSize'])
				: json['pageSize'].toInt();
	}
	if (json['total'] != null) {
		data.total = json['total'] is String
				? int.tryParse(json['total'])
				: json['total'].toInt();
	}
	if (json['totalPage'] != null) {
		data.totalPage = json['totalPage'] is String
				? int.tryParse(json['totalPage'])
				: json['totalPage'].toInt();
	}
	if (json['item'] != null) {
		data.item = (json['item'] as List).map((v) => CashFlowItem().fromJson(v)).toList();
	}
	return data;
}

Map<String, dynamic> cashFlowEntityToJson(CashFlowEntity entity) {
	final Map<String, dynamic> data = new Map<String, dynamic>();
	data['page'] = entity.page;
	data['pageSize'] = entity.pageSize;
	data['total'] = entity.total;
	data['totalPage'] = entity.totalPage;
	data['item'] =  entity.item?.map((v) => v.toJson())?.toList();
	return data;
}

cashFlowItemFromJson(CashFlowItem data, Map<String, dynamic> json) {
	if (json['id'] != null) {
		data.id = json['id'].toString();
	}
	if (json['name'] != null) {
		data.name = json['name'].toString();
	}
	if (json['code'] != null) {
		data.code = json['code'].toString();
	}
	if (json['uuid'] != null) {
		data.uuid = json['uuid'].toString();
	}
	if (json['operateType'] != null) {
		data.operateType = json['operateType'].toString();
	}
	if (json['tradingAccount'] != null) {
		data.tradingAccount = json['tradingAccount'].toString();
	}
	if (json['transAmount'] != null) {
		data.transAmount = json['transAmount'] is String
				? double.tryParse(json['transAmount'])
				: json['transAmount'].toDouble();
	}
	if (json['beforeTransAmount'] != null) {
		data.beforeTransAmount = json['beforeTransAmount'] is String
				? double.tryParse(json['beforeTransAmount'])
				: json['beforeTransAmount'].toDouble();
	}
	if (json['afterTransAmount'] != null) {
		data.afterTransAmount = json['afterTransAmount'] is String
				? double.tryParse(json['afterTransAmount'])
				: json['afterTransAmount'].toDouble();
	}
	if (json['tradingAccountAfterTransAmount'] != null) {
		data.tradingAccountAfterTransAmount = json['tradingAccountAfterTransAmount'] is String
				? double.tryParse(json['tradingAccountAfterTransAmount'])
				: json['tradingAccountAfterTransAmount'].toDouble();
	}
	if (json['recordType'] != null) {
		data.recordType = json['recordType'].toString();
	}
	if (json['stationName'] != null) {
		data.stationName = json['stationName'].toString();
	}
	if (json['recordTypeName'] != null) {
		data.recordTypeName = json['recordTypeName'].toString();
	}
	if (json['operateUser'] != null) {
		data.operateUser = json['operateUser'].toString();
	}
	if (json['desc'] != null) {
		data.desc = json['desc'].toString();
	}
	if (json['operateTime'] != null) {
		data.operateTime = json['operateTime'].toString();
	}
	return data;
}

Map<String, dynamic> cashFlowItemToJson(CashFlowItem entity) {
	final Map<String, dynamic> data = new Map<String, dynamic>();
	data['id'] = entity.id;
	data['name'] = entity.name;
	data['code'] = entity.code;
	data['uuid'] = entity.uuid;
	data['operateType'] = entity.operateType;
	data['tradingAccount'] = entity.tradingAccount;
	data['transAmount'] = entity.transAmount;
	data['beforeTransAmount'] = entity.beforeTransAmount;
	data['afterTransAmount'] = entity.afterTransAmount;
	data['tradingAccountAfterTransAmount'] = entity.tradingAccountAfterTransAmount;
	data['recordType'] = entity.recordType;
	data['stationName'] = entity.stationName;
	data['recordTypeName'] = entity.recordTypeName;
	data['operateUser'] = entity.operateUser;
	data['desc'] = entity.desc;
	data['operateTime'] = entity.operateTime;
	return data;
}